package com.svms.service.search;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * 
 * | no operator (like empty for reset) <br>
 * | = | equals <br>
 * | # | not equal <br>
 * | < | less than <br>
 * | > | greater than <br>
 * | <= | less or equal <br>
 * | >= | greater or equal <br>
 * | ~ | like <br>
 * <br>
 * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++<br>
 * 
 * @author om39a
 */
/**
 * @author om39a
 *
 */
/**
 * @author om39a
 * 
 */
/**
 * @author om39a
 * 
 */
public class SearchOperators implements Serializable {

	private static final long serialVersionUID = 1L;

	private transient int searchOperatorId;
	private transient String searchOperatorSign;
	private transient String searchOperatorName;

	/**
	 * constructor.<br>
	 * 
	 * @param searchOperatorId
	 * @param searchOperatorSign
	 * @param searchOperatorName
	 */
	private SearchOperators(int searchOperatorId, String searchOperatorSign,
			String searchOperatorName) {
		this.searchOperatorId = searchOperatorId;
		this.searchOperatorSign = searchOperatorSign;
		this.searchOperatorName = searchOperatorName;
	}

	public static List<SearchOperators> getAllOperators() {

		List<SearchOperators> result = new ArrayList<SearchOperators>();
		// list position 0
		result.add(new SearchOperators(SearchFilter.OP_NONE, "", "no operator"));
		// list position 1
		result.add(new SearchOperators(SearchFilter.OP_EQUAL, "=", "equals"));
		// list position 2
		result.add(new SearchOperators(SearchFilter.OP_NOT_EQUAL, "#",
				"not equal"));
		// list position 3
		result.add(new SearchOperators(SearchFilter.OP_LESS_THAN, "<",
				"less than"));
		// list position 4
		result.add(new SearchOperators(SearchFilter.OP_GREATER_THAN, ">",
				"greater than"));
		// list position 5
		result.add(new SearchOperators(SearchFilter.OP_LESS_OR_EQUAL, "<=",
				"less or equal"));
		// list position 6
		result.add(new SearchOperators(SearchFilter.OP_GREATER_OR_EQUAL, ">=",
				"greater or equal"));
		// list position 7
		// result.add(new SearchOperators(SearchFilter.OP_ILIKE, "~", "ilike"));
		return result;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + searchOperatorId;
		result = prime
				* result
				+ ((searchOperatorName == null) ? 0 : searchOperatorName
						.hashCode());
		result = prime
				* result
				+ ((searchOperatorSign == null) ? 0 : searchOperatorSign
						.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		SearchOperators other = (SearchOperators) obj;
		if (searchOperatorId != other.searchOperatorId)
			return false;
		if (searchOperatorName == null) {
			if (other.searchOperatorName != null)
				return false;
		} else if (!searchOperatorName.equals(other.searchOperatorName))
			return false;
		if (searchOperatorSign == null) {
			if (other.searchOperatorSign != null)
				return false;
		} else if (!searchOperatorSign.equals(other.searchOperatorSign))
			return false;
		return true;
	}

	public int getSearchOperatorId() {
		return searchOperatorId;
	}

	public void setSearchOperatorId(int searchOperatorId) {
		this.searchOperatorId = searchOperatorId;
	}

	public String getSearchOperatorSign() {
		return searchOperatorSign;
	}

	public void setSearchOperatorSign(String searchOperatorSign) {
		this.searchOperatorSign = searchOperatorSign;
	}

	public String getSearchOperatorName() {
		return searchOperatorName;
	}

	public void setSearchOperatorName(String searchOperatorName) {
		this.searchOperatorName = searchOperatorName;
	}
}
